/////////////////////////////
/// ServiceNow APIs
/////////////////////////////

//TODO:
// * Check target, source, current, previous (GlideRecord or SNow Object [with GET && SET])

/** Variables & Constants **/
declare const GlideEvaluator: GlideEvaluator;
declare const GlideRecord: GlideRecord;
declare const GlideDialogWindow: GlideDialogWindow;
declare const GlideAggregate: GlideAggregate;
declare const GlideAjax: GlideAjax;
declare const GlideDateTime: GlideDateTime;
declare const GlideDate: GlideDate;
declare const GlideTime: GlideTime;
declare const GlideAuditor: GlideAuditor;
declare const ArrayUtil: ArrayUtil;
declare const GlideElementDescriptor: GlideElementDescriptor;
declare const GlideElement: GlideElement;
declare const GlideUpdateManager2: GlideUpdateManager2;
declare const GlideImpersonate: GlideImpersonate;
declare const GlideFilter: GlideFilter;

declare var g_form: GlideForm;
declare var g_list: GlideList;
declare var g_user: GlideUser;
declare var gs: GlideSystem;
declare var g_scratchpad: g_scratchpad;

declare const target: GlideRecord;
declare const source: GlideRecord;
declare const current: GlideRecord;
declare const previous: GlideRecord;

declare const map: object;
declare const log: object;

declare var error: boolean;
declare var action: string;
declare var answer: boolean;

declare var g_user_date_format: object;
declare var g_user_date_time_format: object;

/** Types **/
type RestHTTPMethods = "get" | "post" | "delete" | "patch" | "put" | "head" | "delete" | "options";
type QueryOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "IN" | "STARTSWITH" | "ENDSWITH" | "CONTAINS" | "DOESNOTCONTAIN" | "INSTANCEOF";
type AggregateOperator = "COUNT" | "MAX" | "MIN" | "AVG" | "SUM";


/** Getting Response from Server side on GlideAjax */
declare const response: {
  readonly responseXML: {
    readonly documentElement: {
      /**
       * Get answer from the server side
       * @param answer === "answer"
       * @returns the answer from the server side
       */
      getAttribute(answer: string): string;
    }
  }
};

/** Client Side Date Function **/
/**
 * These used with the getDateFromFormat function gives us an easy way to get a value for the date (essentially a Unix Timestamp).
 * That value can then be used directly or immediately passed into a Javascript Date object to allow for reformatting, testing, or whatever else is needed.
 * Can be converted in a Date like this === "new Date(returned_number);"
 * @param {string} value Value from a specific Date or DateTime field.
 * @param {UserDateFormat} type Depending if the field is Date or DateTime exists two types "g_user_date_format" or "g_user_date_time_format"
 * @returns {number} A number in this format ex.: "Tue May 08 2018 00:00:00 GMT+0100 (Western European Summer Time)", that can be converted in JavaScript Date
 */
declare function getDateFromFormat(value: string, type: g_user_date_format | g_user_date_time_format): number;


/** Service Now Object **/
/**
 * Generic ServiceNow Object with generic functions, GlideRecord / target / source / current / previous will extend from this
 */
interface SNowObject extends Object {
  /* Unique Identifier */
  readonly sys_id: Object | string;
  /* Table name */
  sys_class_name: string;

  /* System properties */
  sys_created_by: string | GlideRecord;
  sys_created_on: string | number | GlideDateTime;
  sys_updated_by: string | GlideRecord;
  sys_updated_on: string | number | GlideDateTime;
  sys_mod_count: string | number;

  /* Other properties (Be carefull this may induce you in ERROR o attribute names)*/
  [key: string]: any;

  /**
   * Retrieves the sys_id of the record.
   * @returns sys_id of record
   */
  getUniqueValue(): string;
}

/**
 * TODO add more functions
 * Client Object (Generic Functions and Properties)
 */
interface ClientObject { }


/**
 * TODO add more functions, will have functions to use on SI client capable (WHAT TODO with .this) ?!?!?!
 * Ajax Object (Generic Functions and Properties)
 */
interface AjaxObject {
  /**
 * Retrieves the value saved.
 * @param parameter Name of the parameter
 * @returns Value of tthat was save on Parameter
 */
  getParameter(parameter: string): string;
}


/**
 * The GlideSystem (referred to by the variable name 'gs' in any server-side JavaScript) API provides a number of convenient methods to get information about the system, the current logged in user, etc.
 */
interface GlideSystem {
  /**
   * Adds an error message for the current session.
   * @param message The message to add.
   */
  addErrorMessage(message: any): void;

  /**
   * Adds an info message for the current session.
   * @param message The message to add.
   */
  addInfoMessage(message: any): void;

  /**
   * Adds a message for the current session.
   * @param message The message
   */
  addMessage(message: any): void;

  /**
   * Adds a message for the current session.
   * @param type Type of message
   * @param message The message
   */
  addMessage(type: string, message: any): void;

  /**
   * Returns the date and time for the beginning of last month in GMT.
   * @returns The GMT beginning of last month, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfLastMonth(): string;

  /**
   * Returns the date and time for the beginning of last week in GMT.
   * @returns The GMT beginning of last week, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfLastWeek(): string;

  /**
   * Returns the date and time for the beginning of next month in GMT.
   * @returns The GMT beginning of next month, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfNextMonth(): string;

  /**
   * Returns the date and time for the beginning of next week in GMT.
   * @returns The GMT beginning of next week, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfNextWeek(): string;

  /**
   * Returns the date and time for the beginning of next year in GMT.
   * @returns The GMT beginning of next year, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfNextYear(): string;

  /**
   * Returns the date and time for the beginning of this month in GMT.
   * @returns The GMT beginning of this month, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfThisMonth(): string;

  /**
   * Returns the date and time for the beginning of this quarter in GMT.
   * @returns The GMT beginning of this quarter, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfThisQuarter(): string;

  /**
   * Returns the date and time for the beginning of this week in GMT.
   * @returns The GMT beginning of this week, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfThisWeek(): string;

  /**
   * Returns the date and time for the beginning of this year in GMT.
   * @returns GMT beginning of this year, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfThisYear(): string;

  /**
   * Returns the date and time for the beginning of today in GMT.
   * @returns The GMT beginning of today, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfToday(): string;

  /**
   * Returns the date and time for the beginning of yesterday in GMT.
   * @returns The GMT beginning of yesterday, in the format yyyy-mm-dd hh:mm:ss.
   */
  beginningOfYesterday(): string;

  /**
   * Will perform a cache.do
   */
  cacheFlush(): void;

  /**
   * Calculate the difference between two dates using the default calendar.
   * @param {string} startDate The starting date to compare in the current user's date format.
   * @param {string} endDate The ending date to compare in the current user's date format.
   * @param {boolean} numericValue If true, the return value will be formatted in number of seconds; if false the return value will be formatted ddd hh:mm:ss.
   * @returns If the numericValue parameter is true, returns the difference between the two dates as an integer number of seconds; if false, returns the difference between the two dates in the format ddd hh:mm:ss.
   */
  calDateDiff(startDate: string, endDate: string, numericValue: boolean): string;

  /**
   * Calculates the difference between two dates.
   * @param startDate The starting date to compare in the current user's date format.
   * @param endDate The ending date to compare in the current user's date format.
   * @param {boolean} numericValue If true, the return value will be formatted in number of seconds; if false the return value will be formatted ddd hh:mm:ss.
   * @returns If the numericValue parameter is true, returns the difference between the two dates as an integer number of seconds; if false, returns the difference between the two dates in the format ddd hh:mm:ss.
   */
  dateDiff(startDate: string | GlideDateTime, endDate: string | GlideDateTime, numericValue: boolean): string;

  /**
   * Generates a date and time for the specified date in GMT.
   * @param date Format: yyy-mm-dd
   * @param range Start, end, or a time in the 24 hour format hh:mm:ss.
   * @returns A date and time in the format yyyy-mm-dd hh:mm:ss. If range is start, the returned value is yyyy-mm-dd 00:00:00; If range is end the return value is yyyy-mm-dd 23:59:59.
   */
  dateGenerate(date: string, range: string): string;

  /**
   * Returns a date and time for a certain number of days ago.
   * @param days Number of days
   * @returns The GMT in the format yyyy-mm-dd hh:mm:ss.
   */
  daysAgo(days: number): string;

  /**
   * Returns the date and time of the beginning of the day for the specified number of days ago.
   * @param days Number of days ago
   * @returns Local date and time for the beginning of the day in the user-defined date time format. If the date time format is not modified from its initial value the format is yyyy-mm-dd hh:mm:ss.
   */
  daysAgoLocal(days: number): string;

  /**
   * Returns a date and time for the end of the day a specified number of days ago.
   * @param days Integer number of days
   * @returns The GMT end of the day in the format yyyy-mm-dd hh:mm:ss.
   */
  daysAgoEnd(days: number): string;

  /**
   * Returns a date and time for the beginning of the day a specified number of days ago.
   * @param days Integer number of days
   * @returns The GMT start of the day in the format yyyy-mm-dd hh:mm:ss.
   */
  daysAgoStart(days: number): string;

  /**
   * Queues an event for the event manager.
   * @param name Name of the event being queued.
   * @param gliderecord A GlideRecord object, such as "current".
   * @param parm1 (Optional) Saved with the instance if specified.
   * @param parm2 (Optional) Saved with the instance if specified.
   * @param queueName (Optional) The name of the queue.
   */
  eventQueue(name: string, gliderecord: GlideRecord, parm1?: string, parm2?: string, queueName?: string): void;

  /**
   * Clears session messages saved using addErrorMessage() or addInfoMessage().
   */
  flushMessages(): void;

  /**
   * Returns the file path to the user's avatar.
   * @returns {string} The file path to the user's avatar.
   */
  getAvatar(): string;

  /**
   * Gets the name of the current scope.
   * @returns {string} The current scope name
   */
  getCurrentScopeName(): string;

  /**
   * Retrieves the display column for the table.
   * @param {string} tableName Name of the table from which to get the display column name.
   * @returns {string} Display column name
   */
  getDisplayColumn(tableName: string): string;

  /**
   * Returns the display value for a specified field on a record.
   * @param {string} tableName	Name of the table
   * @param {string} recordID sysid for the record
   * @param {string} fieldName Name of the field
   * @returns {string} Display value for the field
   */
  getDisplayValueFor(tableName: string, recordID: string, fieldName: string): string;

  /**
   * Returns the list of error messages for the session that were added by addErrorMessage().
   * @returns {string} List of error messages
   */
  getErrorMessages(): string;

  /**
   * Retrieves the property and escapes it for XML parsing.
   * @param {string} key Key for the property whose value should be returned.
   * @param {object} substituteObject Object to be returned if the property is not found.
   * @returns {string} The property, or the substituteObject if the property is not found.
   */
  getEscapedProperty(key: string, substituteObject: object): string;

  /**
   * Returns the display name of the impersonating user.
   * @returns {string} The display name of the impersonating user
   */
  getImpersonatingUserDisplayName(): string;

  /**
   * Returns the name of the impersonating user or null if not impersonating.
   * @returns {string} Name of impersonating user
   */
  getImpersonatingUserName(): string;

  /**
   * Retrieves the list of info messages for the session that were added by addInfoMessage().
   * @returns {string} List of info messages
   */
  getInfoMessage(): string;

  /**
   * Returns the user's initials.
   * @returns {string} The user's initials.
   */
  getInitials(): string;

  /**
   * Returns the link for the object
   * @param {string} tableName Name of the table 
   * @param {string} objectID Sys ID of the record 
   * @returns the link for the object
   */
  generateURL(tableName: string, objectID: string): string;

  /**
   * Retrieves translated messages to display in the UI.
   * @param {string} messageID 	The ID of the message.
   * @param {object} args (Optional) a list of strings or other values defined by java.text.MessageFormat, which allows you to produce language-neutral messages for display to users.
   * @returns {string} The UI message / The message with ticks escaped.
   */
  getMessage(messageID: string, args?: object): string;

  /**
   * Returns the list of messages of the specified type for the session that were added by addMessage().
   * @param {string} type The type of message
   */
  getMessages(type: string): void;

  /**
   * Returns the node name for specified index.
   * @param {object} obj	Object to examine
   * @param {number} index Index from which to get the node name
   * @returns {string} The node's name
   */
  getNodeName(obj: object, index: number): string;

  /**
   * Returns the node value for specified index.
   * @param {object} obj	Object to examine
   * @param {number} index Index from which to get the node name
   * @returns {object} The node's value
   */
  getNodeValue(obj: object, index: number): object;

  /**
   * Returns a user preference.
   * @param {string} key The key for the preference
   * @param {object} Default The default value
   * @returns {string} The preference. If no preference, returns the specified default value.
   */
  getPreference(key: string, Default: object): string;

  /**
   * Gets the value of a Glide property. If the property is not found, returns the alternate value.
   * @param {string} key The key for the property whose value should be returned.
   * @param {object} [alt] (Optional) Alternate object to return if the property is not found.
   * @returns {string}
   * @memberof GlideSystem
   */
  getProperty(key: string, alt?: object): string;

  /**
   * Returns the script error found in the specified script, if there is one.
   * @param {string} script The script to check for errors.
   * @returns {string} The script to check for errors.
   */
  getScriptError(script: string): string;

  /**
   * Returns a GlideSession object.
   * @returns A GlideSession object for the current session
   */
  getSession(): GlideSession;

  /**
   * Returns the GlideSession Session ID.
   * @returns {string} The session ID
   */
  getSessionID(): string;

  /**
   * Returns the style defined for the table, field and value.
   * @param {string} tableName The table name
   * @param {string} fieldName The field name
   * @param {string} fieldValue 	The field value
   * @returns {string} The style
   */
  getStyle(tableName: string, fieldName: string, fieldValue: string): string;

  /**
   * Returns the list of error messages for the session that were added with the trivial flag.
   * @returns {string} List of messages
   */
  getTrivialMessages(): string;

  /**
   * Returns a reference to the user object for the current user.
   * @returns A reference to a user object for the current user
   */
  getUser(): GlideUser;

  /**
   * Returns the name field of the current user (e.g. John Smith, as opposed to smith).
   * @returns {string} The user's display name
   */
  getUserDisplayName(): string;

  /**
   * Returns the sys_id of the current user.
   * @returns {string} The sys_id of the current user.
   */
  getUserID(): string;

  /**
   * Returns the username based on a user ID.
   * @param {string} sys_id A sys_id for a user
   * @returns {string} The username
   */
  getUserNameByUserID(sys_id: string): string;

  /**
   * Returns the username of the current user (e.g., jsmith).
   * @returns {string} Username of the current user
   */
  getUserName(): string;

  /**
   * Constructs an Array of all the nodes and values in an XML document.
   * @param {string} xml The XML document to parse
   * @returns {object} List of names and values
   */
  getXMLNodeList(xml: string): object;

  /**
   * Returns the XML text for the first node in the XML string that matches the XPath query.
   * @param {string} xml An XML string
   * @param {string} xpathQuery The XPath query to match
   * @returns {string} The XML node
   */
  getXMLText(xml: string, xpathQuery: string): string;

  /**
   * Determines if the current user has at least one of the passed-in roles. 
   * @param {string} roleName Comma separated list of roles
   * @returns {boolean} True if the user has at least one of the passed-in roles; otherwise false. Also returns true if the user has the administrator role.
   */
  hasRole(roleName: string): boolean;

  /**
   * Determines if the current user has the specified role within a specified group.
   * @param {string} roleName Name of the role
   * @param {object} group sys_id of the group to check for the specified role
   * @returns {boolean} Returns true when the following conditions are met, otherwise returns false: The logged-in user is assigned to the specified the role; The granted by field on the user role record is set to the specified group; The inherited field on the user role record is false.
   */
  hasRoleInGroup(roleName: string, group: object): boolean;

  /**
   * Returns a date and time for a certain number of hours ago.
   * @param {number} hours 	Number of hours
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss
   */
  hoursAgo(hours: number): string;

  /**
   * Returns a date and time for the end of the hour a certain number of hours ago.
   * @param {number} hours An integer number of hours
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss
   */
  hoursAgoEnd(hours: number): string;

  /**
   * Returns a date and time for the start of the hour a certain number of hours ago.
   * @param {number} hours An integer number of hours
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss
   */
  hoursAgoStart(hours: number): string;

  /**
   * Checks whether the date is the first day of the month.
   * @param {(GlideDateTime | GlideDate)} date 	date object
   * @returns {boolean} True if the date is the first day of the month, false otherwise.
   */
  isFirstDayOfMonth(date: GlideDateTime | GlideDate): boolean;

  /**
   * Checks whether the date is the first day of the week. This uses the ISO standard of Monday being the first day of the week.
   * @param {(GlideDateTime | GlideDate)} date date object
   * @returns {boolean} True if the date is the first day of the month, false otherwise.
   */
  isFirstDayOfWeek(date: GlideDateTime | GlideDate): boolean;

  /**
   * Checks whether the date is the first day of the year.
   * @param {(GlideDateTime | GlideDate)} date date object
   * @returns {boolean} True if the date is the first day of the year, false otherwise.
   */
  isFirstDayOfYear(date: GlideDateTime | GlideDate): boolean;

  /**
   * Checks if the current session is interactive.
   * @returns {boolean} True if the session is interactive.
   */
  isInteractive(): boolean;

  /**
   * Checks whether the date is the last day of the month.
   * @param {(GlideDateTime | GlideDate)} date 	date object
   * @returns {boolean} True if the date is the last day of the month, false otherwise. Uses the ISO standard of Sunday being the last day of the week.
   */
  isLastDayofMonth(date: GlideDateTime | GlideDate): boolean;

  /**
   * Checks whether the date is the last day of the week.
   * @param {(GlideDateTime | GlideDate)} date date object
   * @returns {boolean} True if date is the last day of the week, false otherwise.
   */
  isLastDayOfWeek(date: GlideDateTime | GlideDate): boolean;

  /**
   * Checks whether the date is the last day of the year.
   * @param {(GlideDateTime | GlideDate)} date date object
   * @returns {boolean} True if date is the last day of the year, false otherwise.
   */
  isLastDayOfYear(date: GlideDateTime | GlideDate): boolean;

  /**
   * Determines if the current user is currently logged in.
   * @returns {boolean} True if the current user is logged in, false otherwise.
   */
  isLoggedIn(): boolean;

  /**
   *Determines whether a request comes from a mobile device. This method can be used in UI action conditions and business rules.
   * @returns {boolean} True if the request comes from a mobile device; otherwise, false.
   */
  isMobile(): boolean;

  /**
   * Returns the date and time one week ago in GMT.
   * @returns {string} The date and time one week ago, in the format yyyy-mm-dd hh:mm:ss.
   */
  lastWeek(): string;

  /**
   * Logs a message to the system log and saves it to the syslog table.
   * @param {(object | string | boolean | number | Array | Function)} message The message to log.
   * @param {string} [source] (optional) The source of the message.
   */
  log(message: object | string | boolean | number | Array | Function, source?: string): void;

  /**
   * Logs an error to the system log and saves it to the syslog table.
   * @param {string} message 	The message to log.
   * @param {string} [source] (optional) The source of the message
   */
  logError(message: string, source?: string): void;

  /**
   * Logs a warning to the system log and saves it to the syslog table.
   * @param {string} message 	The message to log.
   * @param {string} [source] (optional) The source of the message
   */
  logWarning(message: string, source?: string): void;

  /**
   * Returns a date and time for a certain number of minutes ago
   * @param {number} minutes An integer number of minutes
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss.
   */
  minutesAgo(minutes: number): string;

  /**
   *  Returns a date and time for the end of the minute a certain number of minutes ago.
   * @param {number} minutes An integer number of minutes
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss
   */
  minutesAgoEnd(minutes: number): string;

  /**
   * Returns a date and time for the start of the minute a certain number of minutes ago.
   * @param {number} minutes 	An integer number of minutes
   * @returns {string} GMT in the format yyyy-mm-dd hh:mm:ss.
   */
  minutesAgoStart(minutes: number): string;

  /**
   * Returns a date and time for a certain number of months ago.
   * @param {number} months	An integer number of months
   * @returns {string} GMT on today's date of the specified month, in the format yyyy-mm-dd hh:mm:ss.
   */
  monthsAgo(months: number): string;

  /**
   * Returns a date and time for the last day of the month a certain number of months ago.
   * @param {number} months	An integer number of months
   * @returns {string} GMT end of the month the specified number of months ago, in the format yyyy-mm-dd hh:mm:ss.
   */
  monthsAgoEnd(months: number): string;

  /**
   * Returns a date and time for the start of the month a certain number of months ago.
   * @param {number} months	An integer number of months
   * @returns {string} GMT start of the month the specified number of months ago, in the format yyyy-mm-dd hh:mm:ss
   */
  monthsAgoStart(months: number): string;

  /**
   * Queries an object and returns true if the object is null or contains an empty string.
   * @param {object} obj 	The object to be checked.
   * @returns {boolean} True if null or empty string; otherwise, false.
   */
  nil(obj: object): boolean;

  /**
   * Returns the current date in UTC.
   * @returns {string} The current date in the user-defined format, in UTC.
   */
  now(): string;

  /**
   * Gets the current date and time in the user-defined format.
   * @returns {String} The current date and time in the user-defined format.
   */
  nowDateTime(): String;

  /**
   * Gets a GlideDateTime object with the current date and time.
   * @returns {GlideDateTime} GlideDateTime object with the current date and time in GMT format.
   */
  nowGlideDateTime(): GlideDateTime;

  /**
   * Returns the current date and time in UTC format.
   * @returns {String} The current UTC date time
   */
  nowNoTZ(): String;

  /**
   * Writes a message to the system log. This method does not write the message to the syslog table unless debug has been activated.
   * @param {(object | string | boolean | number | Array | Function)} message The message to log
   */
  print(message: object | string | boolean | number | Array | Function): void;

  /**
   * Returns a date and time for a certain number of quarters ago.
   * @param {number} quarters An integer number of quarters
   * @returns {string} GMT beginning of the quarter that was the specified number of quarters ago, in the format yyyy-mm-dd hh:mm:ss.
   */
  quartersAgo(quarters: number): string;

  /**
   * Returns a date and time for the last day of the quarter, for a specified number of quarters ago.
   * @param {number} quarters An integer number of quarters
   * @returns {string} GMT end of the quarter that was the specified number of quarters ago, in the format yyyy-mm-dd hh:mm:ss
   */
  quartersAgoEnd(quarters: number): string;

  /**
   * Returns a date and time for the first day of the quarter, for a specified number of quarters ago.
   * @param {number} quarters An integer number of quarters
   * @returns {string} GMT end of the month that was the specified number of quarters ago, in the format yyyy-mm-dd hh:mm:ss
   */
  quartersAgoStart(quarters: number): string;

  /**
   * Sets the specified key to the specified value.
   * @param {string} key The key for the property to be set.
   * @param {string} value The value of the property to be set.
   * @param {string} [description] A description of the property.
   */
  setProperty(key: string, value: string, description?: string): void;

  /**
   * Sets the redirect URI for this transaction, which then determines the next page the user will see.
   * @param {object} URI URI to set as the redirect
   */
  setRedirect(URI: object): void;

  /**
   * Sets the return URI for this transaction. This determines what page the user will be directed to when they return from the next form.
   * @param {object} URI URI to set as the return location.
   */
  setReturn(URI: object): void;

  /**
   * Determines if a database table exists.
   * @param {string} tableName Name of the table
   * @returns {boolean} True if the table exists, false otherwise.
   */
  tableExists(tableName: string): boolean;

  /**
   * Returns the sys_id of the user associated with this session. Use getUserID() instead.
   * @returns {string} sys_id of the current user
   */
  userID(): string;

  /**
   * Deletes all existing workflow operations for the specified GlideRecord.
   * @param {GlideRecord} record The GlideRecord
   */
  workflowFlush(record: GlideRecord): void;

  /**
   * Gets a date and time for a certain number of years ago.
   * @param {number} years An integer number of years
   * @returns {string} GMT beginning of the year that is the specified number of years ago, in the format yyyy-mm-dd hh:mm:ss.
   */
  yearsAgo(years: number): string;

  /**
   * Returns yesterday's time (24 hours ago).
   * @returns {string} GMT for 24 hours ago, in the format yyyy-mm-dd hh:mm:ss
   */
  yesterday(): string;

  /**
   * Will Give access to a script include
   * @param {string} name The anme of the script include
   * @returns {ScriptInclude} The Script Include
   */
  include(name: string): any;

  /**
   * will sleep the instance
   * @param {number} miliseconds number of miliseconds to seep
   */
  sleep(miliseconds: number): void;
}


/**
 * The GlideSession API allows you to find information about the current session.
 */
interface GlideSession {
  /**
   * Clears a session client value previously set with putClientData().
   * @param paramName Name of the client data to clear.
   */
  clearClientData(paramName: string): void;

  /**
   * Returns a session client value previously set with putClientData().
   * @param paramName Name of the client data to retrieve.
   * @returns The client data as a string.
   */
  getClientData(paramName: string): string;

  /**
   * Returns the session's language code.
   * @returns The session's language code.
   */
  getLanguage(): string;

  /**
   * Returns a list of roles for the current user.
   * @returns A comma separated list of roles.
   */
  getRoles(): string;

  /**
   * Returns the name of the session's time zone.
   * @returns The name of the session's time zone.
   */
  getTimeZoneName(): string;

  /**
   * Determines if the current session is interactive.
   * @returns True if the session is interactive.
   */
  isInteractive(): boolean;

  /**
   * Will impersonate other user
   * @param sysId A string with sys ID of the user to imperonate
   */
  impersonate(sysId: string): void;

  /**
   * Determines if the current user is currently logged in.
   * @returns True if the current user is logged in.
   */
  isLoggedIn(): boolean;

  /**
   * Sets a session client value that can be retrieved with getClientData().
   * @param paramName Name of the client parameter to set.
   * @param paramValue Parameter value.
   */
  putClientData(paramName: string, paramValue: string): void;
}


/**
 * The GlideUser API provides access to information about the current user and current user roles.
 * Some of the methods the user need to be in security admin
 */
interface GlideUser {

  /**
   * @returns True if the user exists
   */
  exists(): boolean;

  /**
   * Returns the current user's company sys_id.
   * @returns Company sys_id
   */
  getCompanyID(): string;

  /**
   * returns the current user's department sys_id
   * @returns Department sys_id
   */
  getDepartmentID(): string;

  /**
   * Will return date format of user select ex.: "yyyy-MM-dd HH:mm:ss"
   * @returns String with the date format of the user
   */
  getDateTimeFormat(): string;

  /**
   * Returns the current user's display name.
   * @returns User's display name
   */
  getDisplayName(): string;

  /**
   * Returns the display value of the user's session domain.
   * @returns The display value of the user's session domain.
   */
  getDomainDisplayValue(): string;

  /**
   * Returns the user's email address.
   * @returns User's email address
   */
  getEmail(): string;

  /**
   * Returns the user's first name.
   * @returns User's first name
   */
  getFirstName(): string;

  /**
   * @returns The full name of the user
   */
  getFullName(): string;

  /**
   * Returns the sys_id of the current user.
   * @returns User's sys_id
   */
  getID(): string;

  /**
   * Return the initials of the user
   * @returns a string with the initials of the user
   */
  getInitials(): string;

  /**
   * @returns A string with the language of the user
   */
  getLanguage(): string;

  /**
   * Returns the user's last name.
   * @returns User's last name
   */
  getLastName(): string;

  /**
   * Returns an iterator containing the list of all groups to which the user belongs.
   * @returns A list of sys_ids for the active groups to which the user belongs.
   */
  getMyGroups(): Iterator;

  /**
   * Returns the user ID, or login name, of the current user.
   * @returns User ID
   */
  getName(): string;

  /**
   * Return user record
   * @returns Return a GlideRecord
   */
  getRecord(): GlideRecord;

  /**
   * Returns a list of roles that includes explicitly granted roles, inherited roles, and roles acquired by group membership.
   * @returns List of all roles available to the user
   */
  getRoles(): string[];

  /**
   * Will retreive the Date Format used by the user
   * @returns Time format of the user ex.: HH:mm:ss
   */
  getTimeFormat(): string;

  /**
   * Returns the list of roles explicitly granted to the user.
   * @returns List of roles explicitly assigned to the user
   */
  getUserRoles(): string[];

  /**
   * Determines if the current user has the specified role.
   * @param role Role to check
   * @returns True if the user has the role.
   */
  hasRole(role: string): boolean;

  /**
   * Will say if the user is locked out or not
   * @returns a boolean depending if the user is locked out
   */
  isLockedOut(): boolean;

  /**
   * @returns A string with the Time Zone of the user
   */
  getTZ(): string;

  /**
   * Determines if the current user is a member of the specified group.
   * @param group Group to check
   * @returns True if the user is a member of the group.
   */
  isMemberOf(group: string): boolean;
}


/**
 * The scoped GlideFormScratchpad class implements the g_scratchpad object for scoped applications.
 * The scoped GlideFormScratchpad class has no constructor and no methods. The g_scratchpad object behaves identically for global and scoped applications.
 * Put the data when are on the server side and get the data when in client side
 */
interface g_scratchpad {

  /* Create a property on the object g_scratchpad to store data on server side and retrieve the data on the client side */
  [key: string]: any;
}


/**
 * The GlideEvaluator.
 */
interface GlideEvaluator {

  /**
   * Evaluates String
   * @param paranString String that will be evaluated
   * @returns ...
   */
  evaluateString(paranString: string): Object;
}


/**
 * The GlideDialogWindow API provides methods for displaying a dialog in the current window and frame.
 */
interface GlideDialogWindow {
  /**
   * Provides methods for displaying a dialog in the current window and frame.
   * @param id The name of the UI page to load into the dialog window.
   */
  new(id: string): GlideDialogWindow;

  /**
   * Get current dialog window
   */
  readonly get(): {
    /**
     * Closes the dialog window.
     */
    readonly destroy(): void;
  }

  /**
   * Renders the dialog window.
   */
  render(): void;

  /**
   * Sets a given window property to a specified value.
   * @param name The window property to set.
   * @param value The value for the window property.
   */
  setPreference(name: string, value: string): void;

  /**
   * Sets the size of the dialog window.
   * @param width The width of the dialog window.
   * @param height The height of the dialog window.
   */
  setSize(width: number, height: number): void;

  /**
   * Sets the title of the dialog window.
   * @param title The title for the current window.
   */
  setTitle(title: string): void;
}


/**
 * GlideRecord is used for database operations.
 */
interface GlideRecord extends SNowObject {

  /**
   * Creates an instance of the GlideRecord class for the specified table.
   * @param tableName The table to be used.
   */
  new(type: string): GlideRecord;

  /**
    * Adds a filter to return active records.
    * @returns Filter to return active records.
    */
  addActiveQuery(): GlideQueryCondition;

  /**
   * Changes the domain used for the query from the user's domain to the domain of the provided GlideRecord.
   * @param glideRecord GlideRecord from which to obtain the domain.
   */
  addDomainQuery(glideRecord: GlideRecord): void;

  /**
   * Adds an encoded query to other queries that may have been set.
   * @param query An encoded query string.
   */
  addEncodedQuery(query: string): void;

  /**
   * Applies a pre - defined GlideDBFunctionBuilder object to a record.
   * @param Function A GlideDBFunctionBuilder object that defines a SQL operation.
   */
  addFunction(Function: string): void;

  /**
   * Adds a filter to return inactive records. Inactive records have the active flag set to false.
   * @returns Records where the active flag is false.
   */
  addInactiveQuery(): boolean;

  /**
   * Adds a filter to return records based on a relationship in a related table.
   * @param table Table name
   * @param primaryField (optional) If other than sys_id, the primary field.
   * @param joinTableField (optional) If other than sys_id, the field that joins the tables
   * @returns Records where the relationships match.
   */
  addJoinQuery(table: string, primaryField?: string, joinTableField?: string): GlideQueryCondition;

  /**
    * Adds a filter to return records where the specified field is not null.
     * @param fieldName The field name.
     * @returns QueryCondition of records where the parameter field is not null.
     */
  addNotNullQuery(fieldName: string): GlideQueryCondition;

  /**
   * Adds a filter to return records where the specified field is null.
   * @param fieldName The field name.
   * @returns QueryCondition of records where the specified field is null.
   */
  addNullQuery(fieldName: string): GlideQueryCondition;

  /**
   * Provides the ability to build a request, which when executed, returns the rows from the specified table that match the request.
   * @param name Table field name
   * @param operator Query operator. The available values are dependent on the data type of the value parameter.
   * @param value Value on which to query (not case-sensitive).
   * @returns A reference to the QueryCondition that was added to the GlideRecord.
   */
  addQuery(name: string, operator?: QueryOperator, value: object | string | number | boolean | Array): GlideQueryCondition;

  /**
   * Provides the ability to build a request, which when executed, returns the rows from the specified table that match the request.
   * @param name Table field name
   * @param value Value on which to query (not case-sensitive).
   * @returns A reference to the QueryCondition that was added to the GlideRecord.
   */
  addQuery(name: string, value: object | string | number | boolean | Array): GlideQueryCondition;

  /**
   * Apply a template record(from sys_template) to the current record.If the specified template is not found, no action is taken.
   * @param template Name of a template from the sys_template table
   */
  applyTemplates(template: string): void;

  /**
   * Enables or disables the update to the fields sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on. This is often used for manually updating field values on a record while leaving historical information unchanged.
   * @param boo If false disables updates to sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on.
   */
  autoSysFields(boo: boolean): void;

  /**
   * Determines if the access control rules (which includes the user's role) permit inserting new records in this table.
   * @returns True if the user's role permits creation of new records in the table.
   */
  canCreate(): boolean;

  /**
   * Determines if the access control rules (which includes the user's role) permit deletion of records in this table.
   * @returns True if the user can delete records from this table, false otherwise.
   */
  canDelete(): boolean;

  /**
   * Determines if the access control rules (which includes the user's role) permit reading this table.
   * @returns True if the user can read from this table, false otherwise.
   */
  canRead(): boolean;

  /**
   * Determines if the access control rules (which includes the user's role) permit updates to records in this table.
   * @returns True if the user can write to the table, false otherwise.
   */
  canWrite(): boolean;

  /**
   * Determines whether any of the fields in the record have changed.
   * @returns True if any of the fields in the record have changed, false otherwise.
   */
  changes(): boolean;

  /**
   * Deletes multiple records according to the current "where" clause.
   */
  deleteMultiple(): void;

  /**
   * Deletes a single record.
   * @returns True if the record was deleted; false if none were found to delete.
   */
  deleteRecord(): boolean;

  /**
   * Returns true if any record has a matching value in the specified column. If found, it also moves to the first record that matches, essentially executing next() until the record is returned.
   * @param columnName Specifies the field name.
   * @param value Specifies the value to check for in the specified field.
   * @returns True if any record has a matching value in the specified field.
   */
  find(columnName: string, value: string): boolean;

  /**
   * Creates a GlideRecord based on a specified 'name = value' pair.
   * @param name Field name
   * @param value (Optional) Value to match
   * @return True = GlideRecord was created || False = GlideRecord was not created
   */
  get(name: string, value?: String): boolean;

  /**
   * Creates a GlideRecord based on a specified 'name = value' pair.
   * @param value Value to match (If is sys_id you just need value)
   * @return True = GlideRecord was created || False = GlideRecord was not created
   */
  get(value: String): boolean;

  /**
   * Returns the dictionary attributes on the specified field.
   * @param fieldName Field name for which to return the dictionary attributes
   * @returns Dictionary attributes
   */
  getAttribute(fieldName: string): string;

  /**
   * Returns the table's label.
   * @returns The table's label
   */
  getClassDisplayValue(): string;

  /**
   * Returns the value of the field with the currency symbol and the number with decimals can be use ex.: gr.currency.getCurrencyDisplayValue()
   * @return the value of the currency field (ex.: $100.00)
   */
  getCurrencyDisplayValue(): string;

  /**
   * Retrieves the display value for the current record.
   * @param [fieldName] Name of a field
   * @returns Display value for the current record
   */
  getDisplayValue(fieldName?: string): string;

  /**
   * Returns the element's descriptor.
   * @returns The element's descriptor
   */
  getED(): GlideElementDescriptor;

  /**
   * Retrieves the GlideElement for a specified field.
   * @param fieldName A field name
   * @returns A GlideElement object
   */
  getElement(fieldName: string): GlideElement;

  /**
   * Retrieves the encoded query as a string.
   * @returns The encoded query
   */
  getEncodedQuery(): string;

  /**
   * Retrieves the field value for the display field of the current record and adds escape characters for use in Jelly scripts.
   * @returns Escaped value of display field.
   */
  getEscapedDisplayValue(): string;

  /**
   * Retrieves a Java ArrayList of fields in the current record.
   * @returns Fields in the current record
   */
  getFields(): string[];

  /**
   * Retrieves the field's label.
   * @returns The field's label
   */
  getLabel(): string

  /**
   * Retrieves the link for the current record. 
   * @param noStack If true, the link generated will not append &sysparm_stack=[tablename]_list.do? sysparm_query=active=true to the end of the URL; if false, the link will. Leaving the parameter empty defaults to false.
   * @returns A URL
   */
  getLink(noStack: boolean): string;

  /**
   * Retrieves the current row number.
   * @param boo boolean
   * @returns The row number of the current record
   */
  getLocation(boo: boolean): number;

  /**
   * Retrieves the plural label of the GlideRecord table.
   * @returns The plural label of the GlideRecord 's table.
   */
  getPlural(): string;

  /**
   * Retrieves the class (table) name for the current record.
   * @returns Class or table name
   */
  getRecordClassName(): string;

  /**
   * Retrieves a list of names and display values of tables that refer to the current record.
   * @param boo boolean
   * @returns Hash map with names and display values of related tables.
   */
  getRelatedLists(boo: boolean): object;

  /**
   * Retrieves a list of names and display values of tables that are referred to by the current record.
   * @param boo boolean
   * @returns Hash map with names and display values of related tables.
   */
  getRelatedTables(boo: boolean): object;

  /**
   * Retrieves the number of rows in the GlideRecord object.
   * @returns An integer count of the rows
   */
  getRowCount(): number;

  /**
   * Retrieves the row number set by saveLocation() or setLocation().To get the current row number, use getLocation().
   * @returns The saved row number.
   */
  getRowNumber(): number;

  /**
   * Retrieves the table name associated with this GlideRecord.
   * @returns A table name
   */
  getTableName(): string;

  /**
   * Retrieves the string value of an underlying element in a field.
   * @param fieldName 	Name of a field
   * @returns The string value of the underlying element. Returns null if the field is empty, or the field does not exist.
   */
  getValue(fieldName: string): string;

  /**
   * Determines if the current record has any attachments.
   * @returns True if the current record has attachments, false otherwise.
   */
  hasAttachments(): boolean;

  /**
   * Determines if there are any more records in the GlideRecord.
   * @returns True if there are more records in the query set.
   */
  hasNext(): boolean;

  /**
   * Creates an empty record suitable for population before an insert.
   */
  initialize(): void;

  /**
   * Inserts a new record using the field values that have been set for the current record.
   * @returns The sys_id of the inserted record, or null if the record is not inserted.
   */
  insert(): string;

  /**
   * Inserts a new record and also inserts or updates any related records with the information provided.
   * @returns sys_id for the record inserted, or null if the record was not inserted.
   */
  insertWithReferences(): string;

  /**
   * Checks a table for the type\class of table.
   * @param className 	Name of a type or class of record.
   * @returns True if table is an instance of the specified class.
   */
  instanceOf(className: string): boolean;

  /**
   * Determines whether the current record has been inserted into the database.
   * @returns True if the current record is new (has not been inserted into the database.)
   */
  isNewRecord(): boolean;

  /**
   * Determines if the table exists.
   * @returns True if the table is valid or if the record was successfully fetched, false otherwise.
   */
  isValid(): boolean;

  /**
   * Determines if the specified field is defined in the current table.
   * @param fieldName Name of a field.
   * @returns True if the field is valid, false otherwise.
   */
  isValidField(fieldName: string): boolean;

  /**
   * Determines if the current record is valid.
   * @returns True if the current record is valid or false if past the end of the record set.
   */
  isValidRecord(): boolean;

  /**
   * Creates a GlideRecord, set the default values for the fields and assign a unique id to the record.
   */
  newRecord(): void;

  /**
   * Moves to the next record in the GlideRecord.
   * @returns True if there are more records in the query set.
   */
  next(): boolean;

  /**
   * Retrieves the current operation being performed, such as insert, update, delete, etc.
   * @returns The current operation
   */
  operation(): string;

  /**
   * Specifies a field name to be used to order the query set.This may be called more than once to order by multiple fields.
   * @param fieldName A field name
   */
  orderBy(fieldName: string): void;

  /**
   * Specifies a field used to order the query set in descending order.
   * @param fieldName A field name.
   */
  orderByDesc(fieldName: string): void;

  /** 
   * Runs the query against the table based on the filters specified by addQuery() and addEncodedQuery().
   * @param [field] (Optional) A field name
   * @param [value] (Optional) A value
   */
  query(field?: any, value?: any): void;

  /**
   * Used in domain separated instances.Similar to query(), runs the query against the table based on the filters specified by addQuery() and addEncodedQuery(), but ignores domains.
   * @param field A field name
   * @param value A value
   */
  queryNoDomain(field: object, value: object): void;

  /**
   * Sets the current record to be the record that was saved with saveLocation().If saveLocation() has not been called, the current record is set to be the first record of the GlideRecord.
   */
  restoreLocation(): void;

  /**
   * Saves the current row number so that we can get back to this location using the restoreLocation() method.
   */
  saveLocation(): void;

  /**
   * Sets a flag to indicate if the next database action (insert, update, delete) is to be aborted.
   * @param boo True to abort next action, or false to allow the next action.
   */
  setAbortAction(boo: boolean): void;

  /**
   * Sets the specified field to the specified display value.
   * @param name Field name
   * @param value Display value for the specified field.
   */
  setDisplayValue(name: string, value: object): void;

  /**
   * Updates the record even if fields have not changed.
   * @param force True to update even if fields have not changed, otherwise false.
   */
  setForceUpdate(force: boolean): void;

  /**
   * Sets the limit for how many records are in the GlideRecord.
   * @param limit Limit for records to fetch.
   */
  setLimit(limit: number): void;

  /**
   * Sets the current row location.
   * @param rowNumber The row number to set as the current row.
   */
  setLocation(rowNumber: number): void;

  /**
   * Generates a new GUID and sets it as the unique id for the current record. This function applies only to new records. The GUID for an existing record cannot be changed
   */
  setNewGuid(): void;

  /**
   * Generates a new GUID and sets it as the unique id for the current record, when inserting a new record.
   * @param guid A string value for the new GUID
   */
  setNewGuidValue(guid: string): void;

  /**
   * Enables or disables using the reference field 's display name when querying a reference field.
   * @param queryReferences If true, will generate a string of display names. If false, will generate a string of sys_ids.
   */
  setQueryReferences(queryReferences: boolean): void;

  /**
   * Disables or enables the running of any engines (approval rules / assignment rules).
   * @param boo If true, enables engines. If false disables engines.
   */
  setUseEngines(boo: boolean): void;

  /**
   * Sets the specified field to the specified value.
   * @param name Field name
   * @param value A value to be assigned.
   */
  setValue(name: string, value: any): void;

  /**
   * Enables or disables the running of business rules that might normally be triggered by subsequent actions.
   * @param boo If true (default) enables business rules, and if false to disables them.
   */
  setWorkflow(boo: boolean): void;

  /**
   * Updates the GlideRecord with any changes that have been made.If the record does not exist, it is inserted.
   * @param reason (Optional) A string designating the reason for the update. The reason is displayed in the audit record.
   * @returns Unique id of the new or update record. Returns null if the update fails.
   */
  update(reason?: object): string;

  /**
   * Updates each GlideRecord in the list with any changes that have been made.
   */
  updateMultiple(): void;

  /**
   * Updates a record and also inserts or updates any related records with the information provided.
   * @param [reason] (Optional) A string designating the reasons for the updates. The reason is displayed in the audit record.
   * @returns The sys_id for the record being updated.
   */
  updateWithReferences(reason?: object): string;

  /**
   * Moves to the next record in the GlideRecord.Provides the same functionality as next(), intended to be used in cases where the GlideRecord has a column named next.
   * @returns True if there are more records in the query set.
   */
  _next(): boolean;

  /**
   * Identical to query().This method is intended to be used on tables where there is a column named query.
   * @param [field] (Optional) A field name
   * @param [value] (Optional) A value
   */
  _query(field?: string, value?: object): void;
}


/**
 * GlideAggregate enables you to easily create database aggregation queries.
 */
interface GlideAggregate extends GlideRecord {
  /**
   * Creates an instance of the GlideRecord class for the specified table.
   * @param tableName The table to be used.
   */
  new(tableName: string): GlideAggregate;

  /**
   * Adds an aggregate.
   * @param agg Name of the aggregate to add, for example, COUNT, MIN, or MAX
   * @param name Name of the column to aggregate. null is the default.
   */
  addAggregate(agg: AggregateOperator, name?: string): void;

  /**
   * Adds a "having" element to the aggregate e.g. select category, count(*) from incident group by category HAVING count(*) > 5.
   * @param agg The aggregate to filter on for example, COUNT.
   * @param operator The operator symbol for example <, >, =, !=.
   * @param value The value to query on, for example '5'.
   */
  addHaving(agg: AggregateOperator, operator: QueryOperator, value: string): void;

  /**
   * Adds a "having" element to the aggregate e.g. select category, count(*) from incident group by category HAVING count(*) > 5.
   * @param agg The aggregate to filter on for example, COUNT.
   * @param [fieldName] (optional) Fields name.
   * @param operator The operator symbol for example <, >, =, !=.
   * @param value The value to query on, for example '5'.
   */
  addHaving(agg: AggregateOperator, fieldName?: string, operator: QueryOperator, value: string): void;

  /**
   * Adds a trend for a field.
   * @param fieldName The name of the field for which trending should occur.
   * @param timeInterval The time interval for the trend. The following choices are available: year, quarter, date, week, month, dayofweek, hour, value.
   */
  addTrend(fieldName: string, timeInterval: string): void;

  /**
   * Returns the value of an aggregate from the current record.
   * @param agg The type of the aggregate, for example, SUM or Count.
   * @param name Name of the field to get the aggregate from.
   * @returns The value of the aggregate.
   */
  getAggregate(agg: AggregateOperator, name?: string): string;

  /**
   * Returns the query necessary to return the current aggregate.
   * @returns The query.
   */
  getQuery(): string;

  /**
   * Returns the number of records by summing an aggregate.
   * @param agg The aggregate
   * @param name The name of the field to aggregate
   * @returns The total
   */
  getTotal(agg: AggregateOperator, name?: string): number;

  /**
   * Provides the name of a field to use in grouping the aggregates.
   * @param name Name of the field.
   */
  groupBy(name: string): void;

  /**
   * Provides the name of a field that should be used to order the aggregates. The field will also be added to the group-by list.
   * @param name Name of the field used to order the aggregates.
   */
  orderBy(name: string): void;

  /**
   * Orders the aggregates based on the specified aggregate and field.
   * @param agg	Type of aggregation, for example SUM, COUNT, MIN, MAX.
   * @param name Name of the field to aggregate.
   */
  orderByAggregate(agg: AggregateOperator, name?: string): void;

  /**
   * Sets whether the results are to be grouped.
   * @param boo Set to true if grouping is true, otherwise set to false.
   */
  setGroup(boo: boolean): void;
}


/**
 * Object returned when creating Query;
 * Works in conjunction with any of the addQuery() methods
 */
interface GlideQueryCondition {
  /**
   * Adds an AND condition to the current condition.
   * @param {string} name The name of a field.
   * @param {(object | string | number)} value The value to query on.
   * @returns {GlideQueryCondition}	A reference to a GlideQueryConditon that was added to the GlideRecord.
   */
  addCondition(name: string, value: object | string | number): GlideQueryCondition;

  /**
   * Adds an AND condition to the current condition.
   * @param {string} name The name of a field.
   * @param {QueryOperator} operator (Optional) The operator for the query. If you do not specify an operator, the condition uses an equals operator.
   * @param {(object | string | number)} value The value to query on.
   * @returns {GlideQueryCondition}	A reference to a GlideQueryConditon that was added to the GlideRecord.
   */
  addCondition(name: string, operator: QueryOperator, value: object | string | number): GlideQueryCondition;

  /**
   * Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition.
   * addOrCondition() works in conjunction with any of the addQuery() methods to OR the specified query parameters to the query previously constructed using addQuery().
   * @param {string} name Field name
   * @param {QueryOperator} operator (Optional) Query operator. The available values are dependent on the data type of the value parameter.
   * @param {(object | string | number)} value Value on which to query (not case-sensitive); All passed in arrays must contain a minimum of two elements. Single element arrays are not supported.
   * @returns {GlideQueryCondition} 	A reference to a GlideQueryConditon that was added to the GlideRecord.
   */
  addOrCondition(name: string, operator: QueryOperator, value: object | string | number): GlideQueryCondition;

  /**
   * Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition.
   * addOrCondition() works in conjunction with any of the addQuery() methods to OR the specified query parameters to the query previously constructed using addQuery().
   * @param {string} name Field name
   * @param {(object | string | number)} value Value on which to query (not case-sensitive); All passed in arrays must contain a minimum of two elements. Single element arrays are not supported.
   * @returns {GlideQueryCondition} 	A reference to a GlideQueryConditon that was added to the GlideRecord.
   */
  addOrCondition(name: string, value: object | string | number): GlideQueryCondition;
}


/**
 * The global GlideImpersonate API
 * Use the GlideImpersonate API when you need to act as another user so to test functionality within your application.
 * When impersonating another user, the administrator has access to exactly what the impersonated user would have access to in the system, including the same menus and modules.
 * @interface GlideImpersonate
 */
interface GlideImpersonate {

  /**
  * The global GlideImpersonate API enables administrators to pose as another authenticated user for testing purposes.
  * @Note The system records anything the administrator does while impersonating another user as having been done by that user.
  */
  new(): GlideImpersonate;

  /**
   * Verifies whether the specified user can perform debugging on scripts.
   * @param {string} userSysId sys_Id of the user to verify for debugging capability.
   * @returns {boolean} True: User is able to debug the application. || False: User is not able to debug the application.
   */
  canDebug(userSysId: string): boolean;

  /**
   * Verifies whether the current user can impersonate the specified user.
   * @param {string} userSysId sys_Id of the user to impersonate
   * @returns {boolean} True: Current user can impersonate the specified user. || False: Current user cannot impersonate the specified user.
   */
  canImpersonate(userSysId: string): boolean;

  /**
   * Sets the user ID for the current administrator to the passed-in user ID, enabling the administrator to act as that user.
   * @param {string} userSysId sys_id of the user to impersonate
   * @returns {string} sys_id of the user that was logged in prior to the impersonation request
   */
  impersonate(userSysId: string): string;

  /**
   * Determines whether the current user is impersonating another user.
   * @returns {boolean} True: User is currently impersonating another user. || False: User is not currently impersonating another user.
   */
  isImpersonating(): boolean;
}


/**
 * The GlideAjax class enables a client script to call server-side code in a script include.
 * To use GlideAjax in a client script, follow these general steps.
 */
interface GlideAjax {
  /**
   * Constructor for GlideAjax.
   * @param cass_name The name of the server-side class that contains the method you want to execute.
   */
  new(class_name: string): GlideAjax;

  /**
   * Specifies a parameter name and value to be passed to the server-side function associated with this GlideAjax object.
   * The first call to addParam should be with the parameter sysparm_name and the name of the server-side method you want to call.
   * @param parm_name The name of the parameter to pass. (The name must begin with the sysparm_ .)
   * @param parm_value The value to assign to parm_name.
   */
  addParam(parm_name: string, parm_value: sting): void;

  /**
   * Retrieves the results from a server-side method called from the client via getXMLWait().
   */
  getAnswer(): void;

  /**
   * Sends the server a request to execute the method and parameters associated with this GlideAjax object.
   * @param callback The name of the callback function to process the results returned by the server.
   */
  getXML(callback: Function): void;

  /**
   * Call the processor asynchronously and get the answer element of the response in XML format.
   * @param callback The callback function. The function receives the answer element of the response in XML format as an argument.
   */
  getXMLAnswer(callback: Function): void;

  /**
   * Sends the server a request to execute the method and parameters associated with this GlideAjax object.
   */
  getXMLWait(): void;

  /**
   * Defines the function to be execute if there is an error with the call.
   * @param callback The callback function. The function that executes if the call is not completed successfully.
   */
  setErrorCallback(callback: Function): void;
}


/**
 * Mobile GlideForm (g_form) methods enable you to work with forms on the mobile platform.
 */
interface GlideForm {
  /**
   * Adds a decorative icon next to a field.
   * @param fieldName The field name.
   * @param icon The font icon to show next to the field.
   * @param text The text title for the icon (used for screen readers).
   */
  addDecoration(fieldName: string, icon: string, text: string): void;

  /**
   * Gets the form label text.
   * @param fieldName The field name.
   * @returns The label text.
   */
  getLabel(fieldName: string): string;

  /**
   * Determines if a field is present on the form.
   * @param fieldName The field to look for.
   * @returns True if the field is present on the form; false, if it is not. On the form means that the field is part of g_form. It could still be hidden, read-only, mandatory, or invalid.
   */
  hasField(fieldName: string): boolean;

  /**
   * Determines if the record is a new record.
   * @returns True if is a new Record, otherwise false.
   */
  isNewRecord(): boolean;

  /**
   * Removes a decorative icon from next to a field.
   * @param fieldName The field name.
   * @param icon The icon to remove.
   * @param text The text title for the icon.
   */
  removeDecoration(fieldName: string, icon: string, text: string): void;

  /**
   * Sets the form label text.
   * @param fieldName The field name.
   * @param label The field label text.
   */
  setLabel(fieldName: string, label: string): void;

  /**
   * Will set a value for the select field.
   * @param fieldName The field name.
   * @param value The value for the field
   * @param displayValue display value for the field
   */
  setValue(fieldName: string, value: string, displayValue?: string);

  /**
   * Will get a value for the select field.
   * @param fieldName The field name.
   */
  getValue(fieldName: string);

  /**
   * Will set the selected field to readOnly
   * @param fieldName The field name.
   * @param isReadOnly If true the selected is read only, otherwise no.
   */
  setReadOnly(fieldName: string, isReadOnly: boolean): void;
}

/**
 * GlideList (g_form) methods enable you to work with lists.
 */
interface GlideList {
  /**
   * TODO add g_list methods
   */
}


/**
 * @description The GlideDateTime class provides methods for performing operations on GlideDateTime objects, such as instantiating GlideDateTime objects or working with glide_date_time fields.
 */
interface GlideDateTime {
  /**
   * Instantiates a new GlideDateTime object with the current date and time in Greenwich Mean Time (GMT).
   * @param value The datetime in milliseconds.
   */
  new(value?: string | GlideDateTime): GlideDateTime;

  /**
   * Adds a GlideTime object to the current GlideDateTime object.
   * @param millisecond The number of milliseconds to add. | The GlideTime object to add.
   */
  add(millisecond: number | GlideTime): void;

  /**
   * Adds a specified number of days to the current GlideDateTime object.
   * @param days The number of days to add. Use a negative value to subtract.
   */
  addDaysLocalTime(days: number): void;

  /**
   * Adds a specified number of days to the current GlideDateTime object.
   * @param days The number of days to add. Use a negative number to subtract.
   */
  addDaysUTC(days: number): void;

  /**
   * Adds a specified number of months to the current GlideDateTime object.
   * @param months The number of months to add. use a negative value to subtract.
   */
  addMonthsLocalTime(months: number): void;

  /**
   * Adds a specified number of months to the current GlideDateTime object.
   * @param months The number of months to add. Use a negative value to subtract.
   */
  addMonthsUTC(months: number): void;

  /**
   * Adds the specified number of seconds to the current GlideDateTime object.
   * @param seconds The number of seconds to add.
   */
  addSeconds(seconds: number): void;

  /**
   * Adds a specified number of weeks to the current GlideDateTime object.
   * @param weeks The number of weeks to add. Use a negative value to subtract.
   */
  addWeeksLocalTime(weeks: number): void;

  /**
   * Adds a specified number of weeks to the current GlideDateTime object.
   * @param weeks The number of weeks to add. Use a negative value to subtract.
   */
  addWeeksUTC(weeks: number): void;

  /**
   * Adds a specified number of years to the current GlideDateTime object.
   * @param years The number of years to add. Use a negative value to subtract.
   */
  addYearsLocalTime(years: number): void;

  /**
   * Adds a specified number of years to the current GlideDateTime object.
   * @param years The number of years to add. Use a negative value to subtract.
   */
  addYearsUTC(years: number): void;

  /**
   * Determines if the GlideDateTime object occurs after the specified GlideDateTime.
   * @param gdt	The time to check against.
   * @returns Returns true if the GlideDateTime object's time is after the time specified by the parameter.
   */
  after(gdt: GlideDateTime): boolean;

  /**
   * Determines if the GlideDateTime object occurs before the specified GlideDateTime.
   * @param gdt The time to check against.
   * @returns Returns true if the GlideDateTime object's time is before the time specified by the parameter.
   */
  before(gdt: GlideDateTime): boolean;

  /**
   * Compares two date and time objects to determine whether they are equivalent or one occurs before or after the other.
   * @param gdt Date and time object in GlideDateTime format
   * @returns 0 = Dates are equal || 1 = The object's date is after the date specified in the parameter || -1 = The object's date is before the date specified in the parameter
   */
  compareTo(gdt: GlideDateTime): number;

  /**
   * Compares a datetime with an existing value for equality.
   * @param dateTime The datetime to compare.
   * @returns	Returns true if they are equal; otherwise, false.
   */
  equals(dateTime: GlideDateTime | string): boolean;

  /**
   * Gets the date stored by the GlideDateTime object, expressed in the standard format, yyyy-MM-dd, and the system time zone, UTC by default.
   * @returns	The date in the system time zone.
   */
  getDate(): GlideDate;

  /**
   * Returns the current day of the month in the UTC time zone.
   * @returns The day of the month in the UTC time zone, from 1 to 31.
   */
  getDayOfMonth(): number;

  /**
   * Returns the day of the month stored by the GlideDateTime object, expressed in the current user's time zone.
   * @returns The day of the month in the user's time zone, from 1 to 31.
   */
  getDayOfMonthLocalTime(): number;

  /**
   * Returns the day of the month stored by the GlideDateTime object, expressed in the UTC time zone.
   * @returns The day of the month in the UTC time zone, from 1 to 31.
   */
  getDayOfMonthUTC(): number;

  /**
   * Returns the day of the week stored by the GlideDateTime object, expressed in the user's time zone.
   * @returns The day of the week value - Monday = 1, ... Sunday = 7.
   */
  getDayOfWeek(): number;

  /**
 * Returns the day of the week stored by the GlideDateTime object, expressed in the user's time zone.
 * @returns The day of the week value - Monday = 1, ... Sunday = 7.
 */
  getDayOfWeekLocalTime(): number;

  /**
 * Returns the day of the week stored by the GlideDateTime object, expressed in the UTC time zone.
 * @returns The day of the week value - Monday = 1, ... Sunday = 7.
 */
  getDayOfWeekUTC(): number;

  /**
   * Returns the number of days in the month stored by the GlideDateTime object, expressed in the Java Virtual Machine time zone.
   * @returns The number of days in the current month in the Java Virtual Machine time zone.
   */
  getDaysInMonth(): number;

  /**
    * Returns the number of days in the month stored by the GlideDateTime object, expressed in the current user's time zone.
    * @returns The number of days in the current month in the Java Virtual Machine time zone.
    */
  getDaysInMonthLocalTime(): number;

  /**
   * Returns the number of days in the month stored by the GlideDateTime object, expressed in the UTC time zone.
   * @returns The number of days in the current month in the Java Virtual Machine time zone.
   */
  getDaysInMonthUTC(): number;

  /**
   * Returns the date and time value in the current user's display format and time zone.
   * @returns The date and time in the user's format and time zone. Keep in mind when designing business rules or script includes that this method may return values in different formats for different users.
   */
  getDisplayValue(): string;

  /**
   * Sets a date and time value using the current user's display format and time zone.
   * @param {string} asDisplayed The date and time in the current user's display format and time zone. The parameter must be formatted using the current user's preferred display format, such as MM-dd-yyyy HH:mm:ss.
   */
  setDisplayValue(asDisplayed: string): void;

  /**
   * Sets a date and time value using the current user's time zone and the specified date and time format.
   * @param {string} dateTime The date and time in the current user's time zone.
   * @param {string} format The format to use to parse the dateTime parameter.
   */
  setDisplayValue(dateTime: string, format: string): void;

  /**
   * Determines if a value is a valid date and time.
   */
  isValid(): boolean;

  /**
   * Gets the current error message.
   * @returns {string} The error message
   */
  getErrorMsg(): string;

  /**
   * Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT.
   * @returns {number} The number of milliseconds since January 1, 1970, 00:00:00 GMT.
   */
  getNumericValue(): number;

  /**
   * Gets the date and time value stored by the GlideDateTime object in the internal format, yyyy-MM-dd HH:mm:ss, and the system time zone, UTC by default.
   * @returns {string} The date and time in the internal format and system time zone.
   */
  getValue(): string;
}

/**
 * @description The scoped GlideDate class provides methods for performing operations on GlideDate objects, such as instantiating GlideDate objects or working with GlideDate fields.
 * */
interface GlideDate {

  /**
   * Creates a GlideDate object with the current date time.
   * @returns {string} Creates a GlideDate object with the current date time.
   */
  new(): GlideDate;

  /**
   * Gets the date in the specified date format.
   * @param {string} format the desired date format
   * @returns {string} the date in the specified format
   */
  getByFormat(format: string): string;

  /**
   * Gets the day of the month stored by the GlideDate object, expressed in the UTC time zone.
   * @returns {number} The day of the month in the UTC time zone, from 1 to 31.
   */
  getDayOfMonthNoTZ(): number;

  /**
   * Gets the date in the current user's display format and time zone.
   * @returns {string} The date in the user's format and time zone. Keep in mind when designing business rules or script includes that this method may return values in different formats for different users.
   */
  getDisplayValue(): string;

  /**
   * Gets the display value in the internal format (yyyy-MM-dd).
   * @returns {string} The date values for the GlideDate object in the current user's time zone and the internal time format of yyyy-MM-dd.
   */
  getDisplayValueInternal(): string;

  /**
   * Gets the month stored by the GlideDate object, expressed in the UTC time zone.
   * @returns {number} The numerical value of the month from 1 to 12.
   */
  getMonthNoTZ(): number;

  /**
   * Gets the date value stored in the database by the GlideDate object in the internal format, yyyy-MM-dd, and the system time zone, UTC by default.
   * @returns {string} The date value in the internal format and system time zone.
   */
  getValue(): string;

  /**
   * Gets the year stored by the GlideDate object, expressed in the UTC time zone.
   * @returns {number} The numerical value of the year.
   */
  getYearNoTZ(): number;

  /**
   * Sets a date value using the current user's display format and time zone.
   * @param {string} asDisplayed The date in the current user's display format and time zone. The parameter must be formatted using the current user's preferred display format, such as yyyy-MM-dd.
   */
  setDisplayValue(asDisplayed: string): void;

  /**
   * Sets the date of the GlideDate object.
   * @param {string} date The date and time to use.
   */
  setValue(date: string): void;

  /**
   * Gets the duration difference between two GlideDate values.
   * @param {GlideDate} start The start value.
   * @param {GlideDate} end The end value.
   * @returns {GlideDuration} The duration between the two values.
   */
  subtract(start: GlideDate, end: GlideDate): GlideDuration;
}


/**
 * @description The scoped GlideTime class provides methods for performing operations on GlideTime objects, such as instantiating GlideTime objects or working with GlideTime fields.
 */
interface GlideTime {
  /**
   * Instantiates a GlideTime object with the current time.
   * @param milliseconds (optional) The datetime in milliseconds.
   */
  new(milliseconds?: number): GlideTime;

  /**
   * Gets the time in the specified format
   * @param {string} format The time format
   * @returns {string} The time in the specified format.
   */
  getByFormat(format: string): string;

  /**
   * Gets the time in the current user's display format and time zone.
   * @returns {string} The time in the specified format.
   */
  getDisplayValue(): string;

  /**
   * Gets the display value in the current user's time zone and the internal format (HH:mm:ss).
   * @returns {string} The time value for the GlideTime object in the current user's time zone and the internal time format of HH:mm:ss.
   */
  getDisplayValueInternal(): string;

  /**
   * Returns the hours part of the time using the local time zone.
   * @returns {number} The hours using the local time zone.
   */
  getHourLocalTime(): number;

  /**
   * Returns the hours part of the time using the local time zone. The number of hours is based on a 24 hour clock.
   * @returns {number} The hours using the local time zone. The number of hours is based on a 24 hour clock.
   */
  getHourOfDayLocalTime(): number;

  /**
   * Returns the hours part of the time using the UTC time zone. The number of hours is based on a 24 hour clock.
   * @returns {number} The hours using the UTC time zone. The number of hours is based on a 24 hour clock.
   */
  getHourOfDayUTC(): number;

  /**
   * Returns the hours part of the time using the UTC time zone. The number of hours is based on a 12 hour clock. Noon and midnight are represented by 0, not 12.
   * @returns {number} The hours using the UTC time zone. The number of hours is based on a 12 hour clock. Noon and midnight are represented by 0, not 12.
   */
  getHourUTC(): number;

  /**
   * Returns the number of minutes using the local time zone.
   * @returns {number} The number of minutes using the local time zone.
   */
  getMinutesLocalTime(): number;

  /**
   * Returns the number of minutes in the hour based on the UTC time zone.
   * @returns {number} The number of minutes in the hour using the UTC time zone.
   */
  getMinutesUTC(): number;

  /**
   * Returns the number of seconds in the current minute.
   * @returns {number}	The number of seconds in the minute.
   */
  getSeconds(): number;

  /**
   * Gets the time value stored in the database by the GlideTime object in the internal format, HH:mm:ss, and the system time zone.
   * @returns {string} 	The time value in the internal fomat and system time zone.
   */
  getValue(): string;

  /**
   * Sets a time value using the current user's display format and time zone.
   * @param {string} asDisplaed The time in the current user's display format and time zone. The parameter must be formatted using the current user's preferred display format, such as HH:mm:ss.
   */
  setDisplayValue(asDisplaed: string): void;

  /**
   * Sets the time of the GlideTime object in the internal time zone.
   * @param {string} time The time in hh:mm:ss format.
   * @memberof GlideTime
   */
  setValue(time: string): void;

  /**
   * Gets the duration difference between two GlideTime object values.
   * @param {GlideTime} startTime The start value.
   * @param {GlideTime} endTime The end value.
   * @returns {GlideDuration} The duration between the two values.
   */
  subtract(startTime: GlideTime, endTime: GlideTime): GlideDuration;
}


/**
 * NOT DONE
 * Used on GlideTime
 */
interface GlideDuration {

}


/**
 * NO DOCUMENTATION
 * CREATING DOcumentation
 */
interface GlideAuditor {
  /**
   * 
   * @param className 
   * @param record
   */
  new(className: string, record: GlideRecord): GlideAuditor;

  /**
   * Will create a record on the audit Table
   * @param dontknown ??? can be null
   * @param counter sys_mod_count
   * @param internalCheckpoint Internal value ???
   * @param fieldName Fieldname that was changed
   * @param oldValue old value for that field
   * @param newValue new value for that field
   */
  auditField(dontknown: any, counter: number, internalCheckpoint: number | GlideCounter, fieldName: string, oldValue: string, newValue: string): void;

  /**
   * ???
   * @memberof GlideAuditor
   */
  notifyAll(): void;

}


/**
 * @description ArrayUtil API is a script include with useful functions for working with JavaScript arrays.
 */
interface ArrayUtil {
  /**
   * Instantiates an ArrayUtil
   */
  new(): ArrayUtil;

  /**
   * Merges two arrays.
   * @param paren	An array to merge
   * @param child An array to merge
   * @returns An array of elements from both input arrays. Duplicates are not removed.
   */
  concat(parent: any[], child: any[]): any[];

  /**
   * Searches the array for the element.
   * @param array The array to search
   * @param element The element to search for
   * @returns	True if the element is in the array, false otherwise.
   */
  contains(array: any[], element: any): boolean;

  /**
   * Converts an object to an array.
   * @param a The object to be converted.
   * @returns 	An array created from the object.
   */
  convertArray(a: object): any[];

  /**
   * Finds the differences between two or more arrays.
   * @param a An array
   * @param b An array
   * @returns Returns an array of items from array a that were not found in either array b or c, or other input arrays. Duplicates are removed from the result.
   */
  diff(a: any[], b: any[]): any[];

  /**
   * Returns an array from the object.
   * @param object The object from which to create an array.
   * @returns An array created from the object.
   */
  ensureArray(object: any): any[];

  /**
   * Searches the array for the element.
   * @param array The array to search
   * @param element The element to search for
   * @param startIndex The index to begin the search
   * @returns The index where the element was found, -1 otherwise.
   */
  indexOf(array: any[], element: any, startIndex?: number): number;

  /**
   * Finds the elements present in all arrays.
   * @param a An array
   * @param b An array
   * @returns An array of elements from array a that were found in all of the other input arrays. Duplicates are removed.
   */
  intersect(a: any[], b: any[]): any[];

  /**
   * Merges two or more arrays.
   * @param a An array
   * @param b An array
   * @returns	An array of items from all the input arrays. Duplicates are removed.
   */
  union(a: any[], b: any[]): any[];

  /**
   * Removes duplicate items from an array.
   * @param a The array to check for duplicate elements.
   * @returns An array of unique items from the input array.
   */
  unique(a: any[]): any[];
}


/**
 * @description NOT DONE
 */
interface GlideElementDescriptor { }


/**
 * @description NOT DONE
 */
interface GlideElement { }


/**
 * @description NOT DONE
 */
interface GlideUpdateManager2 {
  /**
   * Instantiates an GlideUpdateManager2
   */
  new(): GlideUpdateManager2;

  /**
   * Will add a specific record to current updatset that user is using
   * @param record The glideRecord that will be save on the updae set
   */
  saveRecord(record: GlideRecord): void;
}


declare namespace sn_ws {
  class RESTMessageV2 {
    /**
     *Creates an instance of RESTMessageV2.
     */
    constructor();

    /**
     *Creates an instance of RESTMessageV2.
     * @param {string} name The name of the REST message record.
     * @param {string} methodName The name of the HTTP method to use, such as GET or PUT.
     */
    constructor(name: string, methodName: string);


    /**
     *Sends the REST message to the endpoint.
     *
     * @returns {RESTResponseV2}
     */
    execute(): RESTResponseV2;

    /**
     *Sends the REST message to the endpoint asynchronously. 
     *The instance does not wait for a response from the web service provider when making asynchronous calls.
     *
     * @returns {RESTResponseV2}
     */
    executeAsync(): RESTResponseV2;

    /**
     *Returns the URL of the endpoint for the REST message.
     *
     * @returns {string}
     */
    getEndpoint(): string;

    /**
     *Returns the content of the REST message body
     *
     * @returns {string}
     */
    getRequestBody(): string;

    /**
     *Returns the value for an HTTP header specified in the REST message.
     *
     * @param {string} headerName The request header you want to get the value for.
     * @returns {string}
     */
    getRequestHeader(headerName: string): string;

    /**
     *Returns HTTP headers that were set by the REST client and the associated values.
     *
     * @returns {object} An Object that maps the name of each header to the associated value.
     */
    getRequestHeaders(): object;

    /**
     *Configures the REST message to save the returned response body as an attachment record.
     *
     * @param {string} tableName Specify the table that contains the record you want to attach the saved file to.
     * @param {string} recordSysId Specify the sys_id of the record you want to attach the saved file to.
     * @param {string} fileName Specify the file name to give to the saved file.
     * @param {string} [encryptContext] Specify the sys_id of an encryption context. The saved file is encrypted using this context.
     */
    saveResponseBodyAsAttachment(tableName: string, recordSysId: string, fileName: string, encryptContext?: string): void;

    /**
     *Sets the credentials for the REST message using an existing basic auth or OAuth 2.0 profile.
     *
     * @param {string} type The type of authentication profile to use. Valid values are 'basic' to use basic authentication, or 'oauth2' to use OAuth 2.0.
     * @param {string} profileId The sys_id of an authentication profile record. When using basic auth, specify the sys_id of a Basic Auth Configuration [sys_auth_profile_basic] record. When using OAuth 2.0, specify the sys_id of a OAuth Entity Profile [oauth_entity_profile] record.
     */
    setAuthenticationProfile(type: string, profileId: string): void;

    /**
     *Sets basic authentication headers for the REST message.
     *
     * @param {string} userName The username you want to use to authenticate the REST message.
     * @param {string} userPass The password for the specified user.
     */
    setBasicAuth(userName: string, userPass: string): void;

    /**
     *Associates outbound requests and the resulting response record in the ECC queue. This method only applies to REST messages sent through a MID Server.
     *
     * @param {string} correlator A unique identifier
     */
    setEccCorrelator(correlator: string): void;

    /**
     *Overrides a value from the database by writing to the REST message payload. This method only applies to REST messages sent through a MID Server.
     *
     * @param {string} name The name of the parameter, such as source.
     * @param {string} value The value to assign to the specified parameter.
     */
    setEccParameter(name: string, value: string): void;

    /**
     *Set the endpoint for the REST message.
     *
     * @param {string} endpoint The URL of the REST provider you want to interface with.
     */
    setEndpoint(endpoint: string): void;

    /**
     *The HTTP method this REST message performs, such as GET or PUT.
     *
     * @param {RestHTTPMethods} method The HTTP method to perform.
     */
    setHttpMethod(method: RestHTTPMethods): void;

    /**
     *Sets the amount of time the REST message waits for a response from the web service provider before the request times out.
     *
     * @param {number} timeoutMs The amount of time, in milliseconds, before the call to the REST provider times out.
     */
    setHttpTimeout(timeoutMs: number): void;

    /**
     *Set the log level for this message and the corresponding response.
     *
     * @param {('basic' | 'elevated' | 'all')} level The log level. Valid values are basic, elevated, and all.
     */
    setLogLevel(level: 'basic' | 'elevated' | 'all'): void;

    /**
     *Configures the REST message to communicate through a MID Server.
     *
     * @param {string} midServer The name of the MID Server to use. Your instance must have an active MID Server with the specified name.
     */
    setMIDServer(midServer: string): void;

    /**
     *Sets the mutual authentication protocol profile for the REST message.
     *
     * @param {string} profileName The Name of the protocol profile to use for mutual authentication.
     */
    setMutualAuth(profileName: string): void;

    /**
     *Append a parameter to the end of the request URL with the form name=value.
     *
     * @param {string} name The name of the URL parameter to pass.
     * @param {string} value The value to assign the URL parameter.
     */
    setQueryParameter(name: string, value: string): void;

    /**
     *Set the body content to send to the web service provider when using PUT or POST HTTP methods.
     *
     * @param {string} body	The request body to send.
     */
    setRequestBody(body: string): void;

    /**
     *Sets the request body using an existing attachment record.
     *
     * @param {string} sys_id The sys_id of the Attachment [sys_attachment] record you want to send in this REST message.
     */
    setRequestBodyFromAttachment(sys_id: string): void;

    /**
     *Set the body content of a PUT or POST message using a binary stream.
     *
     * @param {object} stream 	The binary data to send, such as an attachment or a stream from a 3rd-party service.
     */
    setRequestBodyFromStream(stream: object): void;

    /**
     *Sets an HTTP header in the REST message to the specified value.
     *
     * @param {string} name The name of the header.
     * @param {string} value The value to assign to the specified header.
     */
    setRequestHeader(name: string, value: string): void;

    /**
     *Override the default requestor profile for the REST message in order to retrieve an OAuth access token associated with a different requestor.
     *
     * @param {string} requestorContext
     * @param {string} requestorId
     */
    setRequestorProfile(requestorContext: string, requestorId: string): void;

    /**
     *Sets a REST message function variable with the specified name from the REST message record to the specified value.
     *XML reserved characters in the value are converted to the equivalent escaped characters. Use setStringParameterNoEscape to set a variable without escaping XML reserved characters.
     * 
     * @param {string} name The name of the REST message variable. This parameter must be defined in the REST message record before you can assign a value to it.
     * @param {string} value The value to assign the variable.
     */
    setStringParameter(name: string, value: string): void;

    /**
     *Sets a REST message function variable with the specified name from the REST message record to the specified value.
     *This method is equivalent to setStringParameter but does not escape XML reserved characters.
     * 
     * @param {string} name The name of the REST message variable. This parameter must be defined in the REST message record before you can assign a value to it.
     * @param {string} value The value to assign the variable.
     */
    setStringParameterNoEscape(name: string, value: string): void;
  }

  class SOAPMessageV2 {
    /**
     *Instantiates an empty SOAPMessageV2 object.
     */
    constructor();

    /**
     *Instantiate a SOAPMessageV2 object from a SOAP message record and a function associated with that record.
     * @param {string} soapMessage The SOAP message record you want to use as the base for this object.
     * @param {string} soapFunction The SOAP function you want to execute. Available SOAP functions depend on the WSDL supplied by the web service provider.
     */
    constructor(soapMessage: string, soapFunction: string);

    /**
     *Send the SOAP message to the endpoint.
     *
     * @returns {SOAPResponseV2} The response returned by the SOAP provider.
     */
    execute(): SOAPResponseV2;

    /**
     *Send the SOAP message to the ECC queue.
     *
     * @returns {SOAPResponseV2} The response returned by the SOAP provider.
     */
    executeAsync(): SOAPResponseV2;

    /**
     *Get the endpoint for the SOAP message.
     *
     * @returns {string} The URL of the SOAP web service provider.
     */
    getEndpoint(): string;

    /**
     *Get the content of the SOAP message body.
     *
     * @returns {string} The SOAP message body.
     */
    getRequestBody(): string;

    /**
     *Get the value for an HTTP header specified by the SOAP client.
     *
     * @param {string} headerName The request header you want to get the value for.
     * @returns {string} The value of the specified header.
     */
    getRequestHeader(headerName: string): string;

    /**
     *Get HTTP headers that were set by the SOAP client and the associated values.
     *
     * @returns {object} An Object that maps the name of each header to the associated value.
     * @memberof SOAPMessageV2
     */
    getRequestHeaders(): object;

    /**
     *Set basic authentication headers for the SOAP message.
     *
     * @param {string} userName The username to use when authenticating the SOAP message.
     * @param {string} userPass The password for the specified user.
     */
    setBasicAuth(userName: string, userPass: string): void;

    /**
     *Associate outbound requests and the resulting response record in the ECC queue.
     *
     * @param {string} correlator A unique identifier.
     */
    setEccCorrelator(correlator: string): void;

    /**
     *Override a value from the database by writing to the SOAP message payload.
     *
     * @param {string} name The name of the ECC parameter.
     * @param {string} value The value to assign to the specified ECC parameter.
     */
    setEccParameter(name: string, value: string): void;

    /**
     *Set the endpoint for the SOAP message.
     *
     * @param {string} endpoint The URL of the SOAP web service provider you want to interface with.
     */
    setEndpoint(endpoint: string): void;

    /**
     *Set the amount of time the SOAP message waits for a response from the web service provider before the request times out.
     *
     * @param {number} timeoutMs The amount of time to wait for a response from the web service provider, in milliseconds.
     */
    setHttpTimeout(timeoutMs: number): void;

    /**
     *Set the log level for this message and the corresponding response.
     *
     * @param {('basic' | 'elevated' | 'all')} level The log level. Valid values are basic, elevated, and all.
     */
    setLogLevel(level: 'basic' | 'elevated' | 'all'): void;

    /**
     *Configure the SOAP message to be sent through a MID Server.
     *
     * @param {string} midServer The name of the MID Server you want to send the SOAP message through. Your instance must have an active MID Server with the specified name.
     */
    setMIDServer(midServer: string): void;

    /**
     *Set the mutual authentication protocol profile for the SOAP message.
     *
     * @param {string} profileName The name of the protocol profile to use for mutual authentication.
     */
    setMutualAuth(profileName: string): void;

    /**
     *Set the body content to send to the web service provider.
     *
     * @param {string} body The body of the SOAP message.
     */
    setRequestBody(body: string): void;

    /**
     *Set an HTTP header in the SOAP message to the specified value.
     *
     * @param {string} headerName The name of the header.
     * @param {string} headerValue The value to assign to the specified header.
     */
    setRequestHeader(headerName: string, headerValue: string): void;

    /**
     *Define the SOAP action this SOAP message performs.
     *
     * @param {string} soapAction The SOAP action this SOAP message performs.
     */
    setSOAPAction(soapAction: string): void;

    /**
     *Set a variable with the specified name from the SOAP message record to the specified value.
     *
     * @param {string} name	The name of the SOAP message variable.
     * @param {string} value The value to assign to the specified variable.
     */
    setStringParameter(name: string, value: string): void;

    /**
     *Set a variable with the specified name from the SOAP message record to the specified value.
     *
     * @param {string} name The name of the SOAP message variable.
     * @param {string} value The value to assign to the specified variable.
     */
    setStringParameterNoEscape(name: string, value: string): void;

    /**
     *Sets web service security values for the SOAP message.
     *
     * @param {string} keystoreId The sys_id of the Java or PKCS12 key store to use.
     * @param {string} keystoreAlias The alias that identifies the public and private keys.
     * @param {string} keystorePassword The password assigned to the key store record.
     * @param {string} certificateId The sys_id of the trusted server certificate.
     */
    setWSSecurity(keystoreId: string, keystoreAlias: string, keystorePassword: string, certificateId: string): void;
  }
}

interface RESTResponseV2 {
  /**
   *Return all headers contained in the response, including any duplicate headers.
   *
   * @returns {object} The list of headers contained in the response. Each header is represented as a GlideHTTPHeader object which contains the header name and value.
   */
  getAllHeaders(): object;

  /**
   *Get the content of the REST response body.
   *
   * @returns {string} The REST response body.
   */
  getBody(): string;

  /**
   *Returns all cookies included in the response.
   *
   * @returns {{ size: () => number, get: (index: number) => string }} The list of cookies. Iterate through the list to perform operations on each cookie.
   */
  getCookies(): { size: () => number, get: (index: number) => string };

  /**
   *Get the numeric error code if there was an error during the REST transaction.
   *
   * @returns {number} The numeric error code, such as 1 for socket timeout.
   */
  getErrorCode(): number;

  /**
   *Get the error message if there was an error during the REST transaction.
   *
   * @returns {string} The error message.
   */
  getErrorMessage(): string;

  /**
   *Get the value for a specified header.
   *
   * @param {string} name 	The name of the header that you want the value for, such as Set-Cookie.
   * @returns {string} The value of the specified header.
   */
  getHeader(name: string): string;

  /**
   *Get all headers returned in the REST response and the associated values.
   *
   * @returns {object} An Object that maps the name of each header to the associated value.
   */
  getHeaders(): object;

  /**
   *Get the fully-resolved query sent to the REST endpoint.
   *
   * @returns {string} The fully-resolved query.
   */
  getQueryString(): string;

  /**
   *Get the sys_id value of the attachment created from the response body content.
   *
   * @returns {string} The sys_id of the new attachment record.
   */
  getResponseAttachmentSysid(): string;

  /**
   *Get the numeric HTTP status code returned by the REST provider.
   *
   * @returns {number} The numeric status code returned by the REST provider, such as 200 for a successful response.
   */
  getStatusCode(): number;

  /**
   *Indicate if there was an error during the REST transaction.
   *
   * @returns {boolean} Returns true if there was an error, false if there was no error.
   */
  haveError(): boolean;

  /**
   *Set the amount of time the instance waits for a response from the web service provider.
   *
   * @param {number} timeoutSecs The amount of time, in seconds, to wait for this response.
   */
  waitForResponse(timeoutSecs: number): void;
}

interface SOAPResponseV2 {
  /**
   *Return all headers contained in the response, including any duplicate headers.
   *
   * @returns {object} The list of headers contained in the response. Each header is represented as a GlideHTTPHeader object which contains the header name and value.
   */
  getAllHeaders(): object;

  /**
   *Get the content of the SOAP response body.
   *
   * @returns {string} The SOAP response body.
   */
  getBody(): string;

  /**
   *Returns all cookies included in the response.
   *
   * @returns {object} The list of cookies. Iterate through the list to perform operations on each cookie.
   */
  getCookies(): object;

  /**
   *Get the numeric error code if there was an error during the SOAP transaction.
   *
   * @returns {number} The numeric error code, such as 1 for a socket timeout.
   */
  getErrorCode(): number;

  /**
   *Get the error message if there was an error during the SOAP transaction.
   *
   * @returns {string} The error message.
   */
  getErrorMessage(): string;

  /**
   *Get the value for a specified HTTP header.
   *
   * @param {string} name The name of the header that you want the value for, such as Set-Cookie.
   * @returns {string} The value of the specified header.
   */
  getHeader(name: string): string;

  /**
   *Get all HTTP headers returned in the SOAP response and the associated values.
   *NOTE: If a header is present more than once in the response, such as a Set-Cookie header, this function returns only the last of the duplicate headers. To return all headers including duplicates, use the getAllHeaders() function.
   *
   * @returns {object} An Object that maps the name of each header to the associated value.
   */
  getHeaders(): object;

  /**
   *Get the numeric HTTP status code returned by the SOAP provider.
   *
   * @returns {number} The numeric status code returned by the SOAP provider, such as 200 for a successful response.
   */
  getStatusCode(): number;

  /**
   *Indicate if there was an error during the SOAP transaction.
   *
   * @returns {boolean} Returns true if there was an error, false if there was no error.
   */
  haveError(): boolean;

  /**
   *Set the amount of time the instance waits for a response from the web service provider.
   *
   * @param {number} timeoutSecs The amount of time, in seconds, to wait for this response.
   */
  waitForResponse(timeoutSecs: number): void;
}

/**
 * @description The Scoped GlideFilter API provides a method to determine if a record meets a specified set of requirements. Note: also available in Global scope, but there's only documentation for the Scoped version.
 */
interface GlideFilter {
  /**
   * The method returns true when the record meets the filter condition.
   *
   * @param {GlideRecord} gr The GlideRecord to be evaluated.
   * @param {string} filter An encoded query string.
   * @param {boolean} [matchAll=true] (Optional) If true and the encoded query string contains multiple conditions then all conditions must be true for the method to return true. If false and the encoded query string contains multiple conditions then only one condition needs to be true for the method to return true. If the encoded query string has only one condition, this parameter has no impact.
   */
  checkRecord(gr: GlideRecord, filter: string, matchAll = true): boolean;
}
